var app = getApp();
var api = require('../../../config/api.js');
var util = require('../../../utils/util.js');

Page({
  data: {
    status: 1,
    first_count: 0,
    second_count: 0,
    third_count: 0,
    list: [],
    no_more: !1,
    is_loading: false,
    page: 1
  },
  onLoad: function(t) {
    if (t.status){
      this.setData({
        status: t.status
      })
    }
    this.GetList(1);
  },
  GetList: function(p) {
    var a = this;
    wx.showLoading({
      title: "正在加载",
      mask: !0
    }), util.request(api.team, {
      page: p,
      status:this.data.status
    }).then(function(res) {
      wx.hideLoading();
      console.log(res.data);
      var y = a.data.list;
      if (res.data.list!=null){
        console.log("====");
         y = a.data.list.concat(res.data.list);
        a.setData({
          list: y,
          first_count: res.data.count1,
          second_count: res.data.count2
        })
      }
      if (res.data.list ==null || 5 > res.data.list.length) {
        a.setData({
          no_more: true
        })
      } else {
        a.setData({
          no_more: false
        })
      }
    }).catch((res) => {
      console.log(res);
      wx.hideLoading();
      wx.showModal({
        title: '注意',
        content: '服务器出小差了，请稍候重试.',
        showCancel: false
      });
    })
  },
  onReady: function() {},
  onShow: function() {},
  onHide: function() {},
  onUnload: function() {},
  onReachBottom: function() {
    is_no_more || this.loadData();
  },
  onReachBottom: function() {
    var i = this;
    if (i.data.is_loading == false) {
      var p = i.data.page + 1
      i.setData({
        page: p
      })
      this.GetList(p);

    }
  }
});